package org.hhchat.hiloCoder.code52;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created this one by huminghao on 2018/3/25.
 */
public class P3 {


    static int[] next_edge;
    static int cnt = 0;
    static int[] a;
    static int n;
    static Edge[] e;
    static int[] head;
    static double[][] dp;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        e = new Edge[n];
        head = new int[100005];
        dp = new double[n + 1][2];
        next_edge = new int[n];
        a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        Arrays.fill(head, -1);
        Arrays.fill(next_edge, -1);

        int u, v;
        int father = -1;
        for (int i = 1; i < n; i++) {
            u = scanner.nextInt();
            v = scanner.nextInt();

            if (father == -1 || father == v) {
                father = u;
            }

            e[cnt] = new Edge(u, v);

            next_edge[cnt] = head[u];
            head[u] = cnt++;

        }

        dfs(father);
        double ans = Math.max(dp[father][0], dp[father][1]);
        System.out.printf("%.1f\n", ans);
    }

    public static int dfs(int u) {
        if (u == -1) {
            return 0;
        }
        dp[u][0] = 0;
        dp[u][1] = a[u - 1];
        for (int i = head[u]; i != -1; i = next_edge[i]) {
            int v = e[i].v;
            dfs(v);
            dp[u][0] += Math.max(dp[v][0], dp[v][1]);
            dp[u][1] += Math.max(dp[v][0], dp[v][1] - a[v - 1] / 2.0);
        }
        return 1;
    }



    static class Edge {
        int u;
        int v;

        Edge(int u, int v) {
            this.u = u;
            this.v = v;
        }
    }


}
